<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- Head -->
<head>
    <meta charset="utf-8"/>
    <title>${session.SOFT_NAME }_智能办公系统</title>
    <meta name="description" content="Dashboard"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <%include("/app/resapi/style.html"){}%>
    <link rel="stylesheet" href="/module/zTree_v3/css/bootstrapStyle/bootstrapStyle.css" type="text/css">
    <style type="text/css">
        .js-file {
            cursor: pointer;
        }

        .js-file > span {
            cursor: pointer;
        }

        .filename {
            padding-top: 10px;
            white-space: nowrap;
            display: inline-block;
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
</head>
<body style="overflow-y: auto;">
<div class="page-body" style="padding: 0px;">
    <div class="main-container container-fluid" style="padding: 0px;">
        <div class="page-container" style="padding: 0px;">
            <div class="col-md-12 col-sm-12 col-xs-12" style="padding: 0px;">
                <div class="col-md-2 col-sm-2 col-xs-12" style="padding: 0px;">
                    <div class="widget flat radius-bordered" style="margin-top: 4px;margin-bottom: 5px;">
                        <div class="tabbable">
                            <ul class="nav nav-tabs nav-justified" id="myTab10">
                                <li class="active" style="display: inline-block;"><a data-toggle="tab" href="#myfilediv1"> 个人文件柜 </a></li>
                                <li class="tab-red" style="display: inline-block;"><a data-toggle="tab" href="#sharefilediv2"> 共享文件柜 </a></li>
                            </ul>
                            <div class="tab-content" style="height: 150px;overflow: auto;">
                                <div id="myfilediv1" class="tab-pane in active">
                                    <ul id="tree" class="ztree"></ul>
                                </div>
                                <div id="sharefilediv2" class="tab-pane dd-list">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-10 col-sm-10 col-xs-12" id="dirdiv" style="padding: 0px; background: #ccc; height: 100%">
                    <div class="well with-header  with-footer" style="padding-top: 40px;padding-bottom:40px;padding-left: 0px;padding-right: 0px;margin-bottom: 0px;">
                        <div class="header bordered-blue" id="folderNameHead"></div>
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3" style="margin-top: 50px;" id="fileList">
                            <div class="well bordered-top bordered-bottom bordered-pink">
                                <h4 class="block">消息提示</h4>
                                <p>请选择上方的文件目录!</p>
                            </div>
                        </div>
                        <div class="row" style="margin-left: 0px;background-color: #ccc">
                            <div class="bs-glyphicons">
                                <ul class="bs-glyphicons-list myFileList">
                                </ul>
                            </div>
                            <div class="footer"><code>对文件长按操作</code></div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="col-md-10 col-sm-10 col-xs-12" id="sharediv" style="padding: 0px; background: #ccc; height: 100%;display: none">
                <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3" style="margin-top: 50px;" id="fileList1">
                    <div class="well bordered-top bordered-bottom bordered-pink">
                        <h4 class="block">消息提示</h4>
                        <p>请选择上方的文件目录!</p>
                    </div>
                </div>
                <div class="row" style="margin-left: 0px;">
                    <div class="bs-glyphicons">
                        <ul class="bs-glyphicons-list shareFileList">
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<div class="modal fade bs-example-modal-lg" id="createfoldermodal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myLargeModalLabel">新建目录</h4>
            </div>
            <div class="modal-body">
                <form action="" class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">${i18n('system.sortNo')}</label>
                        <div class="col-sm-10">
                            <input type="number" class="form-control" id="sortNo" name="sortNo" placeholder="${i18n('system.sortNo')}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">文件夹名称:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="folderName" name="folderName" placeholder="文件夹名称">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-warning" data-dismiss="modal">${i18n('cancel')}</button>
                <button type="button" class="btn btn-primary js-foldersave">${i18n('ok')}</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<div class="modal fade bs-example-modal-lg" id="createfilemodal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myLargeModalLabel">新建文件</h4>
            </div>
            <div class="modal-body">
                <form action="" class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">${i18n('system.sortNo')}</label>
                        <div class="col-sm-10">
                            <input type="number" class="form-control" id="fileSortNo" name="fileSortNo" placeholder="${i18n('system.sortNo')}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right" style="padding-top: 2px;">选择文件:</label>
                        <div class="col-sm-10">
                            <div id="show_personalFile"></div>
                            <a class="addfile" href="javascript:void(0)">${i18n('fileupload')} <input data_value="" type="file" onchange="fileUpLoad('personalfile','personalFile');" hidefocus="true" size="1" id="personalFile"
                                                                                                      name="personalFile" class="addfile"/></a>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-warning" data-dismiss="modal">${i18n('cancel')}</button>
                <button type="button" class="btn btn-primary js-filesave">${i18n('ok')}</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<div class="modal fade bs-example-modal-lg" id="renamemodal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myLargeModalLabel">重命名</h4>
            </div>
            <div class="modal-body">
                <form action="" class="form-horizontal" id="form3">
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">文件名称:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="fileName" name="fileName" placeholder="文件名称">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-warning" data-dismiss="modal">${i18n('cancel')}</button>
                <button type="button" class="btn btn-primary js-rename">${i18n('ok')}</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<div class="modal fade bs-example-modal-lg" id="shareFolderModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myLargeModalLabel">共享设置</h4>
            </div>
            <div class="modal-body">
                <form action="" class="form-horizontal" id="form3">
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">共享范围:</label>
                        <div class="col-sm-8">
                            <textarea rows="5" class="form-control" id="sharePriv" name="sharePriv" placeholder="共享范围"></textarea>
                        </div>
                        <div class="col-sm-2">
                            <a style="cursor: pointer;" opt-id="sharePriv" onclick="selectUser(this,'true');">${i18n('system.select')}</a>
                            <a style="cursor: pointer;" onclick="clearSelect('sharePriv')">${i18n('system.clear')}</a>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">编辑权限:</label>
                        <div class="col-sm-8">
                            <textarea rows="5" class="form-control" id="editPriv" name="editPriv" placeholder="编辑权限" readonly="readonly"></textarea>
                        </div>
                        <div class="col-sm-2">
                            <a style="cursor: pointer;" opt-id="editPriv" onclick="selectUser(this,'true');">${i18n('system.select')}</a>
                            <a style="cursor: pointer;" onclick="clearSelect('editPriv')">${i18n('system.clear')}</a>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-warning" data-dismiss="modal">${i18n('cancel')}</button>
                <button type="button" class="btn btn-primary js-setshare">${i18n('ok')}</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<div id="orgselectdiv"></div>
</body>
<%include("/app/resapi/sysjs.html"){}%>
<script type="text/javascript" src="/module/zTree_v3/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="/module/zTree_v3/js/jquery.ztree.excheck.js"></script>
<script type="text/javascript" src="/module/zTree_v3/js/jquery.ztree.exedit.js"></script>
<script type="text/javascript" src="/module/fileupload/ajaxfileupload.js"></script>
<script type="text/javascript" src="/module/fileupload/mobilefileupload.js"></script>
<script type="text/javascript" src="/module/bootstrap-menu/BootstrapMenu.min.js"></script>
<script type="text/javascript">
    var zTree;
    var curLocation = "";// 当前位置
    var fileId = "";
    var fileType = "";
    var optType = ""
    var setting = {
        async: {
            enable: true,// 设置 zTree 是否开启异步加载模式
            url: "/ret/fileget/getPersonalDir",// Ajax 获取数据的 URL 地址
            autoParam: ["folderId"],// 异步加载时需要自动提交父节点属性的参数
        },
        callback: {
            onClick: zTreeOnClick
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "folderId",
                pIdKey: "folderLevel",
                rootPId: "0"
            },
            key: {
                name: "folderName"
            }
        }
    };
    $(function () {
        $.ajax({
            url: "/ret/fileget/getPersonalDir",
            type: "post",
            dataType: "json",
            data: {
                folderId: "0"
            },
            success: function (data) {
                var topNode = [{
                    folderId: "0",
                    folderName: "根目录",
                    isParent: true
                }];
                var newTreeNodes = topNode.concat(data);
                zTree = $.fn.zTree.init($("#tree"), setting, newTreeNodes);// 初始化树节点时，添加同步获取的数据
            }
        });
        $("folderLevelName").unbind("click").click(function (e) {
            e.stopPropagation();
            $("#menuContent").css({
                "width": $(this).outerWidth() + "px"
            }).slideDown(200);
        });
        $("body").unbind("click").click(function () {
            $("#menuContent").hide();
        });

        $("#menuContent").unbind("click").click(function (e) {
            e.stopPropagation();
        });
        new BootstrapMenu("#dirdiv", {
            actions: [{
                name: '新建文件夹',
                onClick: function () {
                    $("#createfoldermodal").modal("show");
                    $(".js-foldersave").unbind("click").click(function () {
                        createFolder();
                    });
                }
            }, {
                name: '新建文件',
                value: $(this).attr("data-value"),
                onClick: function () {
                    $("#createfilemodal").modal("show");
                    $("#show_personalFile").html("");
                    $("#personalFile").attr("data_value", "");
                    $(".js-filesave").unbind("click").click(function () {
                        createFile();
                    });
                }
            }, {
                name: '粘贴',
                onClick: function () {
                    paste();
                }
            }]
        });
        getSharePersonalFileFolder();
    });

    function createFileList(folderId) {
        $(".myFileList").html("");
        var arr = getPersonalFileFolderChild(folderId);
        for (var i = 0; i < arr.length; i++) {
            $(".myFileList").append("<li class='js-floder' ftype='folder' id='file_folder_" + i + "' data-value='" + arr[i].folderId + "' title='" + arr[i].folderName + "'><span style='font-size:40px;color: #428bca;' class='fa fa-folder-open-o'></span><span class='glyphicon-class filename'>" + arr[i].folderName + "</span></li>");
        }

        $(".js-floder").each(function () {
            $(this).unbind("mousedown").mousedown(function (e) {
                $(".js-floder").removeAttr("style");
                $(this).css({
                    "background-color": "#e46f61",
                    "color": "#fff"
                });
                var id = $(this).attr("id");
                var menu = new BootstrapMenu("#" + id, {
                    actions: [{
                        name: '复制',
                        ftype: $(this).attr("ftype"),
                        value: $(this).attr("data-value"),
                        onClick: function () {
                            optType = "2";
                            fileId = this.value;
                            layer.msg("复制文件成功!请选择粘贴位置!");
                            if (this.ftype == "file") {
                                fileType = "file";
                            } else {
                                fileType = "folder";
                            }
                        }
                    }, {
                        name: '剪切',
                        ftype: $(this).attr("ftype"),
                        value: $(this).attr("data-value"),
                        onClick: function () {
                            optType = "1";
                            fileId = this.value;
                            layer.msg("剪切文件成功!请选择粘贴位置!");
                            if (this.ftype == "file") {
                                fileType = "file";
                            } else {
                                fileType = "folder";
                            }
                        }
                    }, {
                        name: '重命名',
                        value: $(this).attr("data-value"),
                        ftype: $(this).attr("ftype"),
                        onClick: function () {
                            rename(this.value, this.ftype);
                        }
                    }, {
                        name: '共享',
                        value: $(this).attr("data-value"),
                        onClick: function () {
                            shareFolder(this.value);
                        }
                    }]
                });
            });
        });
        $.ajax({
            url: "/ret/fileget/getfilelist",
            type: "post",
            dataType: "json",
            data: {
                folderId: folderId
            },
            success: function (data) {
                if (data.status == 200) {
                    for (var i = 0; i < data.list.length; i++) {
                        $(".myFileList").append("<li class='js-file' ftype='file' ext_name=" + data.list[i].extName + " id='file_id_" + i + "' data-value='" + data.list[i].fileId + "' attach='" + data.list[i].attach + "' title='" + data.list[i].fileName + "'><span style='font-size:40px;color: #428bca;' class='" + getfileClass(data.list[i].fileName) + "'></span><span class='glyphicon-class filename'>" + data.list[i].fileName + "</span><span style='padding-top: 5px;' class='glyphicon-class'>" + parseFloat(data.list[i].fileSize / 1024).toFixed(2) + "KB</span></li>");
                    }
                    $(".js-file").each(function () {
                        $(this).unbind("mousedown").mousedown(function (e) {
                            $(".js-file").removeAttr("style");
                            $(this).css({
                                "background-color": "#e46f61",
                                "color": "#fff"
                            });
                            var id = $(this).attr("id");
                            var attachId = $(this).attr("attach");
                            var extName = $(this).attr("ext_name");
                            var optArr = [{
                                name: '复制',
                                ftype: $(this).attr("ftype"),
                                value: $(this).attr("data-value"),
                                onClick: function () {
                                    optType = "2";
                                    fileId = this.value;
                                    layer.msg("复制文件成功!请选择粘贴位置!");
                                    if (this.ftype == "file") {
                                        fileType = "file";
                                    } else {
                                        fileType = "folder";
                                    }
                                }
                            }, {
                                name: '剪切',
                                ftype: $(this).attr("ftype"),
                                value: $(this).attr("data-value"),
                                onClick: function () {
                                    optType = "1";
                                    fileId = this.value;
                                    layer.msg("剪切文件成功!请选择粘贴位置!");
                                    if (this.ftype == "file") {
                                        fileType = "file";
                                    } else {
                                        fileType = "folder";
                                    }
                                }
                            }, {
                                name: '重命名',
                                value: $(this).attr("data-value"),
                                ftype: $(this).attr("ftype"),
                                onClick: function () {
                                    rename(this.value, this.ftype);
                                }
                            }, {
                                name: '编辑',
                                value: $(this).attr("data-value"),
                                onClick: function () {
                                    openFileOnLine(extName, attachId, 4);
                                }
                            },
                                {
                                    name: '历史版本',
                                    value: $(this).attr("data-value"),
                                    onClick: function () {
                                        showFileVersionList(attachId);
                                    }
                                }, {
                                    name: '查看',
                                    value: $(this).attr("data-value"),
                                    onClick: function () {
                                        openFileOnLine(extName, attachId, 1);
                                    }
                                }, {
                                    name: '删除',
                                    value: $(this).attr("data-value"),
                                    ftype: $(this).attr("ftype"),
                                    onClick: function () {
                                        if (this.ftype == "file") {
                                            delFile(this.value);
                                        } else {
                                            delFolder(this.value);
                                        }
                                    }
                                }, {
                                    name: '下载',
                                    value: $(this).attr("data-value"),
                                    onClick: function () {
                                        downFile(this.value);
                                    }
                                }];
                            if (officetype != "3") {
                                optArr.push({
                                    name: '预览',
                                    value: $(this).attr("data-value"),
                                    onClick: function () {
                                        previewonline(attachId);
                                    }
                                });
                            }
                            var menu = new BootstrapMenu("#" + id, {
                                actions: optArr
                            });
                        });
                    });
                } else {
                    console.log(data.msg);
                }
            }
        });

        function previewonline(value) {
            window.open("/app/core/previewonline?attachId=" + value);
        }

        var treeObj = $.fn.zTree.getZTreeObj("tree");
        var nodes = treeObj.getSelectedNodes();
        if (nodes.length > 0) {
            var allNode = nodes[0]['folderName'];// 获取当前选中节点
            var node = nodes[0].getParentNode();
            getParentNodes(node, allNode);
        }
        var location = " <li><i class='fa fa-home'></i></li>";
        var nodeArrs = curLocation.split(">");
        for (var i = nodeArrs.length - 1; i >= 0; i--) {
            location += " <li><a href='#'>" + nodeArrs[i] + "</a></li>";
        }
        $(".breadcrumb").html(location);
        $(".js-floder").each(function () {
            $(this).dblclick(function () {
                var levelFolder = $(this).attr("data-value");
                createFileList(levelFolder);
                $("#fileList").attr("data-value", levelFolder);
                var zTree = $.fn.zTree.getZTreeObj("tree");// treeDemo界面中加载ztree的div
                var node = zTree.getNodeByParam("folderId", $(this).attr("data-value"));
                zTree.selectNode(node, true);// 将指定ID的节点选中
                zTree.expandNode(node, true, false);// 将指定ID节点展开

            })
        });
    }

    function zTreeOnClick(event, treeId, treeNode) {
        $("#sharediv").hide();
        $("#dirdiv").show();
        $("#fileList").hide();
        $("#folderNameHead").html(treeNode.folderName);
        $("#fileList").attr("data-value", treeNode.folderId);
        createFileList(treeNode.folderId);
    }

    function rename(fileId, fType) {
        document.getElementById("form3").reset();
        $("#renamemodal").modal("show");
        $(".js-rename").unbind("click").click(function () {
            if (confirm("确定修改当前文件名称吗？")) {
                $.ajax({
                    url: "/set/fileset/updatePersonalFileFolder",
                    type: "post",
                    dataType: "json",
                    data: {
                        fileId: fileId,
                        type: fType,
                        fileName: $("#fileName").val()
                    },
                    success: function (data) {
                        if (data.status == "200") {
                            layer.msg(sysmsg[data.msg]);
                            $("#renamemodal").modal("hide");
                            var folderId = $("#fileList").attr("data-value");
                            createFileList(folderId)
                        } else {
                            console.log(data.msg);
                        }
                    }
                });

            } else {
                return;
            }
        });
    }

    function paste() {
        if (fileId == "" || fileId == null) {
            layer.msg("请选择需要粘贴的文件!");
            return;
        }
        if (optType == "2") {
            $.ajax({
                url: "/set/fileset/pastePersonalFile",
                type: "post",
                dataType: "json",
                data: {
                    fileId: fileId,
                    currentLocation: $("#fileList").attr("data-value"),
                    type: fileType

                },
                success: function (data) {
                    if (data.status == 200) {
                        layer.msg(sysmsg[data.msg]);
                        location.reload();
                    } else {
                        console.log(data.msg);
                    }
                }
            });
        } else if (optType == "1") {
            if (fileId == "" || fileId == null) {
                layer.msg("请选择需要粘贴的文件!");
                return;
            }
            $.ajax({
                url: "/set/fileset/shearPersonalFile",
                type: "post",
                dataType: "json",
                data: {
                    fileId: fileId,
                    currentLocation: $("#fileList").attr("data-value"),
                    type: fileType

                },
                success: function (data) {
                    if (data.status == 200) {
                        layer.msg(sysmsg[data.msg]);
                        location.reload();
                    } else {
                        console.log(data.msg);
                    }
                }
            });
        }
    }

    function downFile(fileId) {
        window.open("/ret/fileget/getFileDown?fileId=" + fileId);
    }

    function getPersonalFileFolderChild(folderId) {
        var returnArr;
        $.ajax({
            url: "/ret/fileget/getPersonalFileFolderChild",
            type: "post",
            dataType: "json",
            async: false,
            data: {
                folderId: folderId,
            },
            success: function (data) {
                if (data.status == "200") {
                    returnArr = data.list;
                } else {
                    console.log(data.msg);
                }
            }
        });
        return returnArr;
    }

    function createFolder() {
        $.ajax({
            url: "/set/fileset/insertPersonalFileFolder",
            type: "post",
            dataType: "json",
            data: {
                sortNo: $("#sortNo").val(),
                folderName: $("#folderName").val(),
                folderLevel: $("#fileList").attr("data-value")
            },
            success: function (data) {
                if (data.status == 200) {
                    layer.msg(sysmsg[data.msg]);
                    createFileList($("#fileList").attr("data-value"));
                    $("#createfoldermodal").modal("hide");

                } else {
                    console.log(data.msg);
                }
            }
        });
    }

    function delFolder(folderId) {
        $.ajax({
            url: "/set/fileset/delPersonalFolder",
            type: "post",
            dataType: "json",
            data: {
                folderId: folderId
            },
            success: function (data) {
                if (data.status == 200) {
                    layer.msg(sysmsg[data.msg]);
                    location.reload();
                } else {
                    console.log(data.msg);
                }
            }
        });
    }

    function delFile(fileId) {
        $.ajax({
            url: "/set/fileset/delPersonalFile",
            type: "post",
            dataType: "json",
            data: {
                fileId: fileId
            },
            success: function (data) {
                if (data.status == 200) {
                    layer.msg(sysmsg[data.msg]);
                    createFileList($("#fileList").attr("data-value"));
                } else {
                    console.log(data.msg);
                }
            }
        });
    }

    function createFile() {
        $.ajax({
            url: "/set/fileset/insertPersonalFile",
            type: "post",
            dataType: "json",
            data: {
                sortNo: $("#fileSortNo").val(),
                folderId: $("#fileList").attr("data-value"),
                attach: $("#personalFile").attr("data_value")
            },
            success: function (data) {
                if (data.status == 200) {
                    layer.msg(sysmsg[data.msg]);
                    createFileList($("#fileList").attr("data-value"));
                    $("#createfilemodal").modal("hide");
                } else {
                    console.log(data.msg);
                }
            }
        });
    }

    function getParentNodes(node, allNode) {
        if (node != null) {
            allNode += ">" + node['folderName'];
            curNode = node.getParentNode();
            getParentNodes(curNode, allNode);
        } else {
            // 根节点
            curLocation = allNode;
        }
    }

    function getfileClass(filename) {
        var point = filename.lastIndexOf(".");
        var type = filename.substr(point)
        if (type == ".txt") {
            return "fa fa-file-text";
        } else if (type == ".pdf") {
            return "fa fa-file-pdf-o";
        } else if (type == ".xls" || type == ".xlsx") {
            return "fa fa-file-excel-o";
        } else if (type == ".doc" || type == ".docx" || type == ".wps" || type == ".dot") {
            return "fa fa-file-word-o";
        } else if (type == ".jpg" || type == ".png" || type == ".bpm") {
            return "fa fa-file-image-o";
        } else if (type == ".rar" || type == ".zip" || type == ".gz" || type == ".tar") {
            return "fa fa-file-zip-o";
        } else if (type == ".ppt" || type == ".pptx" || type == ".ppts") {
            return "fa fa-file-powerpoint-o";
        } else {
            return "fa fa-file";
        }
    }

    function shareFolder(folderId) {
        $("#sharePriv").attr("data-value", "");
        $("#sharePriv").val("");
        $("#editPriv").attr("data-value", "");
        $("#editPriv").val("");
        $("#shareFolderModal").modal("show");
        $.ajax({
            url: "/ret/fileget/getPersonalFolderById",
            type: "post",
            dataType: "json",
            data: {
                folderId: folderId
            },
            success: function (data) {
                if (data.status == "200") {
                    var info = data.list;
                    $("#editPriv").attr("data-value", info.editPriv);
                    $("#editPriv").val(getUserNameByStr(info.editPriv));
                    $("#sharePriv").attr("data-value", info.sharePriv);
                    $("#sharePriv").val(getUserNameByStr(info.sharePriv));
                } else if (data.status == "100") {
                    console.log(data.msg);
                } else if (data.status == "500") {
                    console.log(data.msg);
                }
            }
        });
        $(".js-setshare").unbind("click").click(function () {
            $.ajax({
                url: "/set/fileset/updatePersonalFileFolderPriv",
                type: "post",
                dataType: "json",
                data: {
                    folderId: folderId,
                    editPriv: $("#editPriv").attr("data-value"),
                    sharePriv: $("#sharePriv").attr("data-value")
                },
                success: function (data) {
                    if (data.status == "200") {
                        layer.msg(sysmsg[data.msg]);
                    } else if (data.status == "100") {
                        console.log(data.msg);
                    } else if (data.status == "500") {
                        console.log(data.msg);
                    }
                    $("#shareFolderModal").modal("hide");
                }
            });
        })
    }


    function getSharePersonalFileFolder() {
        $.ajax({
            url: "/ret/fileget/getSharePersonalFileFolder",
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.status == "200") {
                    var recordList = data.list;
                    for (var i = 0; i < recordList.length; i++) {

                        $("#sharefilediv2").append("<li class=\"dd-item bordered-danger\"><a onclick=\"getShareFile('" + recordList[i].folderId + "');\" class=\"dd-handle\" style=\"cursor: pointer;\">" + recordList[i].folderName + "<span style=\"margin-left: 20px;\">【" + recordList[i].createUserName + ")】</span></a></li>");
                    }
                } else if (data.status == "100") {
                    console.log(data.msg);
                } else if (data.status == "500") {
                    console.log(data.msg);
                }
            }
        });
    }


    function getShareFile(folderId) {
        $("#dirdiv").hide();
        $("#sharediv").show();
        var editPriv = false;
        var sharePriv = false;
        $("#fileList1").hide();
        $("#fileList").attr("data-value", folderId);
        $.ajax({
            url: "/ret/fileget/getShareFolderPrivInfo",
            type: "post",
            dataType: "json",
            async: false,
            data: {
                folderId: folderId
            },
            success: function (data) {
                if (data.status == 200) {
                    editPriv = data.list.editPriv;
                    sharePriv = data.list.sharePriv;
                } else if (data.status == "100") {
                    console.log(data.msg);
                } else if (data.status == "500") {
                    console.log(data.msg);
                }

            }
        })
        $(".shareFileList").html("");
        $.ajax({
            url: "/ret/fileget/getSharefilelist",
            type: "post",
            dataType: "json",
            data: {
                folderId: folderId
            },
            success: function (data) {
                if (data.status == 200) {
                    for (var i = 0; i < data.list.length; i++) {
                        $(".shareFileList ").append("<li class='js-file' ftype='file' ext_name=" + data.list[i].extName + " id='file_id_" + i + "' data-value='" + data.list[i].fileId + "' attach='" + data.list[i].attach + "' title='" + data.list[i].fileName + "'><span style='font-size:40px;color: #428bca;' class='" + getfileClass(data.list[i].fileName) + "'></span><span class='glyphicon-class filename'>" + data.list[i].fileName + "</span><span style='padding-top: 5px;' class='glyphicon-class'>" + parseFloat(data.list[i].fileSize / 1024).toFixed(2) + "KB</span></li>");
                    }
                    $(".js-file").each(function () {
                        $(this).unbind("mousedown").mousedown(function (e) {
                            $(".js-file").removeAttr("style");
                            $(this).css({
                                "background-color": "#e46f61",
                                "color": "#fff"
                            });
                            var id = $(this).attr("id");
                            var attachId = $(this).attr("attach");
                            var extName = $(this).attr("ext_name");
                            var optArr
                            if (editPriv) {
                                optArr = [{
                                    name: '编辑',
                                    value: $(this).attr("data-value"),
                                    onClick: function () {
                                        openFileOnLine(extName, attachId, 4);
                                    }
                                },
                                    {
                                        name: '历史版本',
                                        value: $(this).attr("data-value"),
                                        onClick: function () {
                                            showFileVersionList(attachId);
                                        }
                                    }, {
                                        name: '查看',
                                        value: $(this).attr("data-value"),
                                        onClick: function () {
                                            openFileOnLine(extName, attachId, 1);
                                        }
                                    }, {
                                        name: '下载',
                                        value: $(this).attr("data-value"),
                                        onClick: function () {
                                            downFile(this.value);
                                        }
                                    }];
                                if (officetype != "3") {
                                    optArr.push({
                                        name: '预览',
                                        value: $(this).attr("data-value"),
                                        onClick: function () {
                                            previewonline(attachId);
                                        }
                                    });
                                }
                                var menu = new BootstrapMenu("#" + id, {
                                    actions: optArr
                                });
                            } else {
                                if (sharePriv) {
                                    optArr = [{
                                        name: '查看',
                                        value: $(this).attr("data-value"),
                                        onClick: function () {
                                            openFileOnLine(extName, attachId, 1);
                                        }
                                    }];
                                    if (officetype != "3") {
                                        optArr.push({
                                            name: '预览',
                                            value: $(this).attr("data-value"),
                                            onClick: function () {
                                                previewonline(attachId);
                                            }
                                        });
                                    }
                                    var menu = new BootstrapMenu("#" + id, {
                                        actions: optArr
                                    });
                                }
                            }
                        });
                    });
                } else {
                    console.log(data.msg);
                }
            }
        });
    }


</script>
</html>
